#pragma once
#include "DirectoryListing.h"
#include "gstring.h"
using namespace std;
/// <summary>
/// File operations that are different for different operating systems. This (Linux compiliation) has not been fully implemented yet.
/// </summary>
class FileOperations
{
public:
	/// <summary>
	/// Delete a file in a way that works for all operating systems.
	/// </summary>
	/// <param name="file"></param>
	static bool FileDelete(const gstring& file);
	/// <summary>
	/// Delete a directory in a way that works for all operating systems.
	/// </summary>
	/// <param name="directory"></param>
	static bool DirectoryDelete(const gstring& directory);
	/// <summary>
	/// Creates a directory in a way that works for all operating systems.
	/// </summary>
	/// <param name="directory"></param>
	/// <returns></returns>
	static bool DirectoryCreate(const gstring& directory);
	/// <summary>
	/// What character separates a directory from a file name in this operating system.
	/// </summary>
	/// <returns></returns>
	static gchar DirectorySeparator();
	/// <summary>
	/// Returns true if the folder exists.
	/// </summary>
	/// <param name="folder">Folder to look for</param>
	/// <returns>Returns true if the folder exists.</returns>
	static bool DoesFolderExist(const gstring& folder);
	/// <summary>
	/// Returns true if file names are case sensitive.
	/// </summary>
	/// <returns></returns>
	static bool AreFileNamesCaseSensitive();
	/// <summary>
	/// Reads a directory listing
	/// </summary>
	/// <param name="directory">Directory to read</param>
	/// <param name="directoryListing">Calls AddFile in this object once for each file</param>
	static void ReadDirectory(const gstring& directory, DirectoryListing *directoryListing);
	/// <summary>
	/// Copy a file, maybe at a slower speed.
	/// </summary>
	/// <param name="sourceFullName">File to copy</param>
	/// <param name="targetFullName">New file destination</param>
	/// <param name="speed">100 = full speed, </param>
	/// <returns></returns>
	static bool CopyTheFile(const gstring& sourceFullName, const gstring& targetFullName, int speed);
	/// <summary>
	/// Moves a file from one folder to another within a hard drive.
	/// </summary>
	/// <param name="source">File to move</param>
	/// <param name="target">New location</param>
	static void MoveAFile(const gstring& source, const gstring& target);
	/// <summary>
	/// Sleep a specified number of milliseconds.
	/// </summary>
	/// <param name="delay">Delay in milliseconds</param>
	static void SleepMilliseconds(int delay);
	/// <summary>
	/// Convert a file date from number of seconds since the creation of disco to YYYY-MM-DD HH:mm:ss PM
	/// </summary>
	/// <param name="fileTime">number of seconds since the creation of disco </param>
	/// <param name="output">YYYY-MM-DD HH:mm:ss PM</param>
	static void FileDateToString(INT64 fileTime,gstring &output);
	/// <summary>
	/// Print a gstring.
	/// </summary>
	/// <param name="output">gstring to print</param>
	static void Print(const gstring& output);
	/// <summary>
	/// Prints a number with comma separators for thousands.
	/// </summary>
	/// <param name="n">Number to output</param>
	static void Print(INT64 n);
private:
#if defined WIN32 || defined _WIN32 || defined __CYGWIN__
	/// <summary>
	/// Gets error messages for windows.
	/// </summary>
	static BOOL GetErrorMessage(DWORD dwErrorCode, LPTSTR pBuffer, DWORD cchBufferLength);
#endif
};

